﻿@using VideoSeller.Business.Data.Enums
@model AdminOnlineViewModel

<table>
	<tr>
		<th>@(string.IsNullOrEmpty(Model.LoginFilter) ? @Html.GetGlobalResource("AdminCommon", "All") : Model.LoginFilter)</th>
		<th>@Html.GetGlobalResource("AdminCommon", "SortBy") <a href="@Url.Action(Model.ContentType.ToString(), "Admin", new {loginFilter = Model.LoginFilter, time = Model.SortByTime.HasValue && Model.SortByTime.Value == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending})">@Html.GetGlobalResource("AdminCommon", "TimeSort")</a> | 
			<a href="@Url.Action(Model.ContentType.ToString(), "Admin", new {loginFilter = Model.LoginFilter, views = Model.SortByViews.HasValue && Model.SortByViews.Value == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending})">@Html.GetGlobalResource("AdminCommon", "Views")</a> | 
			<a href="@Url.Action(Model.ContentType.ToString(), "Admin", new {loginFilter = Model.LoginFilter, claims = Model.SortByClaims.HasValue && Model.SortByClaims.Value == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending})">claims</a></th>
	</tr>
	@foreach (var item in Model.Items) {
		<tr>
			<td>
				<a href="@Url.Action("Content", "Home", new { id = item.Id })" target="_blank">
					<img src="@Url.GetThumbnailImage(item.ImageUrl, ThumbnailImageSize.Small)" style="width: 200px; height: 100px;"/>
				</a><br/>
			</td>
			<td>
				<label>@item.Title</label><br/>
				<label>@item.CreatedTime.ToString("dd MMMM yyyy")</label><br/>
				@using (Html.BeginForm("DeleteContent", "Admin", new {contentType = Model.ContentType, itemId = item.Id, loginFilter = Model.LoginFilter, time = Model.SortByTime, views = Model.SortByViews, claims = Model.SortByClaims}, FormMethod.Post, new {style = "float: left;"})) {
					<input type="submit" value="@Html.GetGlobalResource("AdminCommon", "Delete")"/><br/>
					@Html.HttpMethodOverride(HttpVerbs.Delete)
				}
				@using (Html.BeginForm("Refund", "Admin", new {contentType = Model.ContentType, itemId = item.Id, loginFilter = Model.LoginFilter, time = Model.SortByTime, views = Model.SortByViews, claims = Model.SortByClaims}, FormMethod.Post, new {style = "float: left;"})) {
					<input type="submit" value="@Html.GetGlobalResource("AdminCommon", "Refund")"/><br/>
				}
			</td>
		</tr>
	}
</table>

@if (Model.FilterViewModel.Total > 50) {
	<ul class="paging">
		@Html.Paging(Model.FilterViewModel.PageNumber, Model.FilterViewModel.PageCount, x => Url.Action(Model.FilterViewModel.Action, Model.FilterViewModel.Controller, new
		{
			page = x,
			loginFilter = Model.LoginFilter,
			time = Model.SortByTime,
			views = Model.SortByViews,
			claims = Model.SortByClaims
		}))
	</ul>
	<div class="ui-helper-clearfix"></div><br/>
}